const path = require('path');
const fs = require('fs');
const os = require('os');

const dirpath = path.resolve('./data');
const mPath = path.resolve( './db/merge.txt' );
fs.readdir( dirpath , (err,dirs)=>{
    // console.log(data);
    dirs.forEach(item=>{
        let filepath = path.join( dirpath , item );
        // console.log(filepath);
        fs.readFile( filepath , 'utf-8' , (err,data1)=>{
            console.log(data1);
            if( !err ){
                fs.appendFile( mPath , `${data1}${os.EOL}` , (err)=>{
                    if( !err ){
                        console.log('写入成功');
                    }else{
                        console.log('写入失败');
                    }
                } )
            }
        } )
    })
} )